package com.ruoyi.web.controller.jypc;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.jypc.domain.Tb1Spec;
import com.ruoyi.jypc.service.ITb1SpecService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专业信息Controller
 * 
 * @author xymc
 * @date 2022-11-14
 */
@RestController
@RequestMapping("/jypc/spec")
public class Tb1SpecController extends BaseController
{
    @Autowired
    private ITb1SpecService tb1SpecService;

    /**
     * 查询专业信息列表
     */
    @PreAuthorize("@ss.hasPermi('jypc:spec:list')")
    @GetMapping("/list")
    public TableDataInfo list(Tb1Spec tb1Spec)
    {
        startPage();
        List<Tb1Spec> list = tb1SpecService.selectTb1SpecList(tb1Spec);
        return getDataTable(list);
    }

    /**
     * 导出专业信息列表
     */
    @PreAuthorize("@ss.hasPermi('jypc:spec:export')")
    @Log(title = "专业信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Tb1Spec tb1Spec)
    {
        List<Tb1Spec> list = tb1SpecService.selectTb1SpecList(tb1Spec);
        ExcelUtil<Tb1Spec> util = new ExcelUtil<Tb1Spec>(Tb1Spec.class);
        util.exportExcel(response, list, "专业信息数据");
    }

    /**
     * 获取专业信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('jypc:spec:query')")
    @GetMapping(value = "/{spId}")
    public AjaxResult getInfo(@PathVariable("spId") Long spId)
    {
        return AjaxResult.success(tb1SpecService.selectTb1SpecBySpId(spId));
    }

    /**
     * 新增专业信息
     */
    @PreAuthorize("@ss.hasPermi('jypc:spec:add')")
    @Log(title = "专业信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Tb1Spec tb1Spec)
    {
        return toAjax(tb1SpecService.insertTb1Spec(tb1Spec));
    }

    /**
     * 修改专业信息
     */
    @PreAuthorize("@ss.hasPermi('jypc:spec:edit')")
    @Log(title = "专业信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Tb1Spec tb1Spec)
    {
        return toAjax(tb1SpecService.updateTb1Spec(tb1Spec));
    }

    /**
     * 删除专业信息
     */
    @PreAuthorize("@ss.hasPermi('jypc:spec:remove')")
    @Log(title = "专业信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{spIds}")
    public AjaxResult remove(@PathVariable Long[] spIds)
    {
        return toAjax(tb1SpecService.deleteTb1SpecBySpIds(spIds));
    }
}
